-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor merge base logic and fix x fmt
#130161
Conversation
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Compare to `get_git_merge_base`, this doesn't require configuring the upstream remote. Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
This PR changes how LLVM is built. Consider updating src/bootstrap/download-ci-llvm-stamp. This PR modifies If appropriate, please update |
This comment has been minimized.
This comment has been minimized.
Just noting that |
Does |
|
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Some changes occurred in src/tools/compiletest cc @jieyouxu |
Oh, so configuring the remote just fixes this: fmt warning: Something went wrong running git commands:
fmt warning: rust-lang/rust remote not found so there is another problem (if there is truly no change at all, bootstrap should skip formatting files) to solve. |
I think that the problem is simply that when no files are modified, untracked or ignored, then the |
I fixed it already with e392454. It was quite simple to figure out. |
x fmt
You can r=me with the added comment. |
This comment has been minimized.
This comment has been minimized.
There's a "no" missing here, right? |
Won't that make #101907 worse again when the local branch is a miri (or other tool) sync -- which contains local, non-upstream bors commits, from the "other bors" running in the other repo? See #113588 and #115409 for some context of why the logic currently works the way it does. OTOH, things are already not reliably working for these miri syncs, so... it's probably not worth preserving the current half-working state. |
Yes..
I don't see how this could make #101907 worse, as we don't change any behavior for CI-LLVM in this PR. If the most recent bors commit isn't from upstream, then bootstrap will attempt to modify some more files in addition to the ones actually changed. |
e392454
to
d376d74
Compare
This comment has been minimized.
This comment has been minimized.
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
991a60d
to
52419fc
Compare
Oh we are using different "upstream base commit" logic for LLVM and formatting? That seems even worse, to be honest...^^ |
@@ -153,10 +154,9 @@ pub fn prebuilt_llvm_config(builder: &Builder<'_>, target: TargetSelection) -> L | |||
/// This retrieves the LLVM sha we *want* to use, according to git history. | |||
pub(crate) fn detect_llvm_sha(config: &Config, is_git: bool) -> String { | |||
let llvm_sha = if is_git { | |||
helpers::get_closest_merge_base_commit( | |||
get_closest_merge_commit( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This here makes it look like the logic for finding the LLVM commit will change. So I am confused by your statement saying that it will not change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We just moved bootstrap function to build_helper crate.
Previously formatting and LLVM had different "merge base commit" logic, this PR makes formatting to use the LLVM logic. |
src/tools/build_helper/src/git.rs
Outdated
git.current_dir(git_dir); | ||
} | ||
|
||
let merge_base = get_git_merge_base(config, git_dir).unwrap_or_else(|_| "HEAD".into()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, so of upstream is available this will start at the upstream merge base and then find the nearest commit from there. The doc comment of this function doesn't mention that so I got confused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the "If it fails to find the upstream remote," part, it looks quite clear to me actually 🤔
rust/src/tools/build_helper/src/git.rs
Lines 115 to 119 in 5f32717
/// Searches for the nearest merge commit in the repository that also exists upstream. | |
/// | |
/// If it fails to find the upstream remote, it then looks for the most recent commit made | |
/// by the merge bot by matching the author's email address with the merge bot's email. | |
pub fn get_closest_merge_commit( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That only explains what it does when it does not find the upstream remote, it says nothing about what it does when it finds the upstream remote.
The "that also exists upstream" part is the key thing that was missing for me to understand what happens.
src/tools/compiletest/src/lib.rs
Outdated
@@ -163,7 +163,8 @@ pub fn parse_config(args: Vec<String>) -> Config { | |||
) | |||
.optopt("", "edition", "default Rust edition", "EDITION") | |||
.reqopt("", "git-repository", "name of the git repository", "ORG/REPO") | |||
.reqopt("", "nightly-branch", "name of the git branch for nightly", "BRANCH"); | |||
.reqopt("", "nightly-branch", "name of the git branch for nightly", "BRANCH") | |||
.reqopt("", "git-merge-commit-email", "email address used for the merge commits", "EMAIL"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"the" here should be removed.
Also, this is used to find merge commits, not to create them, right? It should specifically be the bors email? That's not clear at all currently, neither here nor in the code.
src/tools/build_helper/src/git.rs
Outdated
@@ -107,6 +109,38 @@ pub fn get_git_merge_base( | |||
Ok(output_result(git.arg("merge-base").arg(&updated_master).arg("HEAD"))?.trim().to_owned()) | |||
} | |||
|
|||
/// Searches for the nearest merge commit in the repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Searches for the nearest merge commit in the repository. | |
/// Searches for the nearest merge commit in the repository that also exists upstream. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am fine with adding that comment, but in rare cases it's not correct (like you mentioned at #130161 (comment)).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even in those cases, the merge commit exists upstream. It's just not the one we wanted...
src/tools/build_helper/src/git.rs
Outdated
/// To work correctly, the upstream remote must be properly configured using `git remote add <name> <url>`. | ||
/// In most cases `get_closest_merge_commit` is the function you are looking for as it doesn't require remote | ||
/// to be configured. | ||
fn get_git_merge_base(config: &GitConfig<'_>, git_dir: Option<&Path>) -> Result<String, String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe "git_upstream_merge_base" would be more clear?
Previously both used get_closest_merge_base_commit, now both use get_closest_merge_commit... seems like they used the same logic before as well? |
Formatting logic uses get_git_modified_files to find changed files, which was utilizing "get_git_merge_base" before, and now it uses "get_closest_merge_commit". |
Oh sorry, I was looking at the wrong place. oops |
Signed-off-by: onur-ozkan <work@onurozkan.dev>
52419fc
to
5f32717
Compare
This should be ready to land if everyone is happy with the recent changes. |
x fmt
x fmt
Fine by me. |
LGTM, thanks! |
@bors r=Kobzol,RalfJung |
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#129260 (Don't suggest adding return type for closures with default return type) - rust-lang#129520 (Suggest the correct pattern syntax on usage of unit variant pattern for a struct variant) - rust-lang#129866 (Clarify documentation labelling and definitions for std::collections) - rust-lang#130123 (Report the `note` when specified in `diagnostic::on_unimplemented`) - rust-lang#130161 (refactor merge base logic and fix `x fmt`) - rust-lang#130206 (Map `WSAEDQUOT` to `ErrorKind::FilesystemQuotaExceeded`) - rust-lang#130207 (Map `ERROR_CANT_RESOLVE_FILENAME` to `ErrorKind::FilesystemLoop`) - rust-lang#130219 (Fix false positive with `missing_docs` and `#[test]`) - rust-lang#130221 (Make SearchPath::new public) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#130161 - onur-ozkan:fmt-changed-files, r=Kobzol,RalfJung refactor merge base logic and fix `x fmt` When remote upstream is not configured, using [get_git_modified_files](https://github.com/rust-lang/rust/blob/38e3a5771cefc9362976a605549f8b04d5707311/src/tools/build_helper/src/git.rs#L114) to find modified files fails because [get_rust_lang_rust_remote](https://github.com/rust-lang/rust/blob/38e3a5771cefc9362976a605549f8b04d5707311/src/tools/build_helper/src/git.rs#L46-L48) can not resolve "rust-lang/rust" from the git output. The changes in this PR makes bootstrap to find the latest bors commit, treating it as the "closest upstream commit" so that the change tracker logic can use it to find the diffs. In addition, [skips formatting](rust-lang@e392454) if there are no modified files. Fixes rust-lang#130147
When remote upstream is not configured, using get_git_modified_files to find modified files fails because get_rust_lang_rust_remote can not resolve "rust-lang/rust" from the git output. The changes in this PR makes bootstrap to find the latest bors commit, treating it as the "closest upstream commit" so that the change tracker logic can use it to find the diffs.
In addition, skips formatting if there are no modified files.
Fixes #130147